<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\Common;

class WeChatCode
{
    protected $uniacid;
    protected $config;
    protected $access_token;
    public function __construct($uniacid)
    {
        $this->uniacid = $uniacid;
        $this->config = longbingGetAppConfig($uniacid);
        $this->access_token = $this->getAccessToken();
    }
    public function getAccessToken()
    {
        return longbingGetAccessToken($this->uniacid, true);
    }
    public function getQRCode($path, $width = 430)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" . $this->access_token;
        $post_data = ["path" => $path, "width" => $width];
        $result = longbingCurl($url, json_encode($post_data, true), "POTH");
        return $result;
    }
    public function getWxCode($path, $width = 430, $auto_color = true, $line_color = NULL, $is_hyaline = false)
    {
        $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" . $this->access_token;
        $post_data = ["path" => $path, "width" => $width, "auto_color" => $auto_color, "line_color" => $line_color, "is_hyaline" => $is_hyaline];
        $result = longbingCurl($url, json_encode($post_data, true), "POTH");
        return $result;
    }
    public function getUnlimitedCode($scene, $path = "", $width = 430, $auto_color = false, $line_color = "{\"r\":0,\"g\":0,\"b\":0}", $is_hyaline = true)
    {
        $access_token = $this->access_token;
        $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $access_token;
        $post_data = ["scene" => $scene];
        if(!empty($width)) {
            $post_data["width"] = $width;
        }
        if(!empty($auto_color)) {
            $post_data["auto_color"] = $auto_color;
        }
        if(!empty($is_hyaline)) {
            $post_data["is_hyaline"] = $is_hyaline;
        }
        if(!empty($path)) {
            $post_data["page"] = $path;
        }
        $result = longbingCurl($url, json_encode($post_data, true), "POST");
        return $result;
    }
}

?>